import request from '@/utils/request'
const UpmsEmailSettingService = {
  state: {},

  mutations: {},

  actions: {
    /**
     * 根据用户和类型获取邮箱
     */
    getEmailConfigByUserIdAndType({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('emailSetting/getEmailConfigByUserIdAndType', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 邮箱配置
     */
    configSystemEmail({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('emailSetting/configSystem', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    /**
     * 邮箱配置保存 已整理
    */
    emailConfigSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('emailSetting/save', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 邮箱配置更新 已整理
    */
    emailConfigUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('emailSetting/update/' + params.id, params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    /**
     * 发送测试邮件
     */
    sendTestEmail({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('emailSetting/sendTest', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }

  }
}

export default UpmsEmailSettingService
